package test.demo;

import com.alibaba.fastjson.JSON;
import tech.waterism.modelbase.PredictBase;
import tech.waterism.modelbase.PredictResult;

import java.util.*;

/**
 * 蓄满产流模型
 * 系统模型集成
 *
 * @author 潘晓健
 * @version 1.0
 */
public class SM extends PredictBase {

    private double B;
//    private double C;
//    private double WUMx;
//    private double WUM;
//    private double WLMx;
//    private double WLM;
//    private double WDM;
    private double WM;
    private double WMM;
//    private double KG;
//    private double KI;
//    private double SMM;
//    private double SM;
//    private double EX;
//    private double IM;
    private double WP;
//    private double WUP;
//    private double WLP;
//    private double WDP;
//    private double SP;
//    private double FRP;
    private double K;
    private double[] ES;
    private double PE;
    private Date[] TM;
    private double[] PP;
    private double T;

    public SM(Map<String, String> data) {
        super();

//        IM = Double.parseDouble(data.get("IM"));
        B = Double.parseDouble(data.get("B"));
        K = Double.parseDouble(data.get("K"));
//        KG = Double.parseDouble(data.get("KG"));
//        KI = Double.parseDouble(data.get("KI"));
//        C = Double.parseDouble(data.get("C"));
        WM = Double.parseDouble(data.get("WM"));
//        SM = Double.parseDouble(data.get("SM"));
//        WUMx = Double.parseDouble(data.get("WUMx"));
//        WLMx = Double.parseDouble(data.get("WLMx"));
//        EX = Double.parseDouble(data.get("EX"));
        ES = JSON.parseObject(data.get("ES"), double[].class);
        WP = Double.parseDouble(data.get("WP"));
//        WUP = Double.parseDouble(data.get("WUP"));
//        WLP = Double.parseDouble(data.get("WLP"));
//        WDP = Double.parseDouble(data.get("WDP"));
//        SP = Double.parseDouble(data.get("SP"));
//        FRP = Double.parseDouble(data.get("FRP"));
        TM = JSON.parseObject(data.get("dt"), Date[].class);             // input[i].data.dt
        PP = JSON.parseObject(data.get("rain"), double[].class);  // input[i].data.rain
        T = Double.parseDouble(data.get("clen"));
    }

    public Map<String, double[]> SMS3model() {

        double DIV = 5.0;
        WMM = (1.0 + B) * WM;

        int Pnum = PP.length;

        double[] W = new double[Pnum + 1];
//        double[] RSP = new double[Pnum];
//        double[] RIP = new double[Pnum];
//        double[] RGP = new double[Pnum];
        double[] RP = new double[Pnum];
        W[0] = WP;

        for (int i = 0; i < Pnum - 1; i++) {
            int IDAY = 31;
            Calendar time = Calendar.getInstance();
            time.setTime(TM[i]);
            Integer Mth = time.get(Calendar.MONTH) + 1; // 获得降雨开始月份
            switch (Mth) {
                case 4:
                case 6:
                case 9:
                case 11:
                    IDAY = 30;
                    break;
                case 2:
                    IDAY = 28;
                    break;
                default:
                    break;
            }
            double EM = ES[Mth - 1] / (IDAY * 24.0 / T);
            double EK = K * EM;
            PE = PP[i] - EK;
            if (PE >= 2 * DIV) {
                int ND = (int) Math.floor(PE / DIV);
                double[] PED = new double[ND];
                double[] RD = new double[ND];
                for (int II = 0; II < ND - 1; II++) {
                    PED[II] = DIV;
                }
                PED[ND - 1] = PE - (ND - 1) * DIV;

                Map<String, Double> WMap = YIELD1(EK, W[i], RD, PED, ND);
                W[i + 1] = WMap.get("W");
                RP[i] = WMap.get("R");
            } else {
                int ND = 1;
                double[] PED = new double[ND];
                double[] RD = new double[ND];
                PED[0] = PE;
                Map<String, Double> map = YIELD1(EK, W[i], RD, PED, ND);
                W[i + 1] = map.get("W");
                RP[i] = map.get("R");
            }
        }

        Map<String, double[]> simulationResult = new HashMap<>();

        simulationResult.put("RunoffSim", RP);
        simulationResult.put("WP", W);

        return simulationResult;
    }

    private Map<String, Double> YIELD1(double EK, double W, double[] RD, double[] PED,
                                       int ND) {
        double R = 0.0;
        if (PE <= 0.0) {
            if (W + PE >= 0.0) {
                W = W + PE;
            } else {
                W = 0.0;
            }
        } else {
            double A = 0.0;
            if (WM - W < 0.0001) {
                A = WMM;
            } else {
                A = WMM * (1.0 - Math.pow((1.0 - W / WM), (1.0 / (1.0 + B))));
            }

            double PEDS = 0.0;
            for (int I = 0; I < ND; I++) {
                A = A + PED[I];
                PEDS = PEDS + PED[I];
                double RI = R;
                R = PEDS - WM + W;
                if (A < WMM) {
                    R = R + WM * Math.pow((1.0 - A / WMM), (1.0 + B));
                }
                RD[I] = R - RI;
            }
            if (W + PE - R <= WM) {
                W = W + PE - R;
            } else {
                W = WM;
            }
        }
        Map<String, Double> WResult = new HashMap<>();
        WResult.put("W", W);
        WResult.put("R", R);
        return WResult;
    }

    private List<String> toStringList(double[] array0) {
        String[] array = new String[array0.length];
        for (int i = 0; i < array.length; i++) {
            array[i] = String.valueOf(array0[i]);
        }
        return Arrays.asList(array);
    }

    @Override
    public void init() {

    }

    @Override
    public PredictResult predict() {
        PredictResult result = new PredictResult();
        Map<String, double[]> map = SMS3model();
        double[][] RSim = new double[1][];
        //流域地表产流
        RSim[0] = map.get("RunoffSim");

        //流域面积总产流 R
        result.setRunoffSim(map.get("RunoffSim"));

        result.setRSim(RSim);

        // 更新状态
        List<String> WP = toStringList(map.get("WP"));
        Map<String, List<String>> status = new HashMap<>();
        //张力水含量
        status.put("WP", WP);
        result.setNewStatus(status);

        return result;
    }

    public static void main(String[] args) {
        String a = "{\"K\":\"0.98\",\"clen\":\"3\",\"dt\":\"[\\\"2020-05-31 08:00:00\\\",\\\"2020-05-31 14:00:00\\\",\\\"2020-05-31 20:00:00\\\",\\\"2020-06-01 02:00:00\\\",\\\"2020-06-01 08:00:00\\\",\\\"2020-06-01 14:00:00\\\",\\\"2020-06-01 20:00:00\\\",\\\"2020-06-02 02:00:00\\\",\\\"2020-06-02 08:00:00\\\",\\\"2020-06-02 14:00:00\\\",\\\"2020-06-02 20:00:00\\\",\\\"2020-06-03 02:00:00\\\",\\\"2020-06-03 08:00:00\\\",\\\"2020-06-03 14:00:00\\\",\\\"2020-06-03 20:00:00\\\",\\\"2020-06-04 02:00:00\\\",\\\"2020-06-04 08:00:00\\\",\\\"2020-06-04 14:00:00\\\",\\\"2020-06-04 20:00:00\\\",\\\"2020-06-05 02:00:00\\\",\\\"2020-06-05 08:00:00\\\",\\\"2020-06-05 14:00:00\\\",\\\"2020-06-05 20:00:00\\\",\\\"2020-06-06 02:00:00\\\",\\\"2020-06-06 08:00:00\\\",\\\"2020-06-06 14:00:00\\\",\\\"2020-06-06 20:00:00\\\",\\\"2020-06-07 02:00:00\\\",\\\"2020-06-07 08:00:00\\\",\\\"2020-06-07 14:00:00\\\",\\\"2020-06-07 20:00:00\\\",\\\"2020-06-08 02:00:00\\\",\\\"2020-06-08 08:00:00\\\",\\\"2020-06-08 14:00:00\\\",\\\"2020-06-08 20:00:00\\\",\\\"2020-06-09 02:00:00\\\",\\\"2020-06-09 08:00:00\\\",\\\"2020-06-09 14:00:00\\\",\\\"2020-06-09 20:00:00\\\",\\\"2020-06-10 02:00:00\\\",\\\"2020-06-10 08:00:00\\\",\\\"2020-06-10 14:00:00\\\",\\\"2020-06-10 20:00:00\\\",\\\"2020-06-11 02:00:00\\\",\\\"2020-06-11 08:00:00\\\",\\\"2020-06-11 14:00:00\\\",\\\"2020-06-11 20:00:00\\\",\\\"2020-06-12 02:00:00\\\",\\\"2020-06-12 08:00:00\\\",\\\"2020-06-12 14:00:00\\\",\\\"2020-06-12 20:00:00\\\",\\\"2020-06-13 02:00:00\\\",\\\"2020-06-13 08:00:00\\\",\\\"2020-06-13 14:00:00\\\",\\\"2020-06-13 20:00:00\\\",\\\"2020-06-14 02:00:00\\\",\\\"2020-06-14 08:00:00\\\",\\\"2020-06-14 14:00:00\\\",\\\"2020-06-14 20:00:00\\\",\\\"2020-06-15 02:00:00\\\",\\\"2020-06-15 08:00:00\\\",\\\"2020-06-15 14:00:00\\\",\\\"2020-06-15 20:00:00\\\",\\\"2020-06-16 02:00:00\\\",\\\"2020-06-16 08:00:00\\\",\\\"2020-06-16 14:00:00\\\",\\\"2020-06-16 20:00:00\\\",\\\"2020-06-17 02:00:00\\\",\\\"2020-06-17 08:00:00\\\",\\\"2020-06-17 14:00:00\\\",\\\"2020-06-17 20:00:00\\\",\\\"2020-06-18 02:00:00\\\",\\\"2020-06-18 08:00:00\\\",\\\"2020-06-18 14:00:00\\\",\\\"2020-06-18 20:00:00\\\",\\\"2020-06-19 02:00:00\\\",\\\"2020-06-19 08:00:00\\\",\\\"2020-06-19 14:00:00\\\",\\\"2020-06-19 20:00:00\\\",\\\"2020-06-20 02:00:00\\\",\\\"2020-06-20 08:00:00\\\",\\\"2020-06-20 14:00:00\\\",\\\"2020-06-20 20:00:00\\\",\\\"2020-06-21 02:00:00\\\",\\\"2020-06-21 08:00:00\\\",\\\"2020-06-21 14:00:00\\\",\\\"2020-06-21 20:00:00\\\",\\\"2020-06-22 02:00:00\\\",\\\"2020-06-22 08:00:00\\\",\\\"2020-06-22 14:00:00\\\",\\\"2020-06-22 20:00:00\\\",\\\"2020-06-23 02:00:00\\\",\\\"2020-06-23 08:00:00\\\",\\\"2020-06-23 14:00:00\\\",\\\"2020-06-23 20:00:00\\\",\\\"2020-06-24 02:00:00\\\",\\\"2020-06-24 08:00:00\\\",\\\"2020-06-24 14:00:00\\\",\\\"2020-06-24 20:00:00\\\",\\\"2020-06-25 02:00:00\\\",\\\"2020-06-25 08:00:00\\\",\\\"2020-06-25 14:00:00\\\",\\\"2020-06-25 20:00:00\\\",\\\"2020-06-26 02:00:00\\\",\\\"2020-06-26 08:00:00\\\",\\\"2020-06-26 14:00:00\\\",\\\"2020-06-26 20:00:00\\\",\\\"2020-06-27 02:00:00\\\",\\\"2020-06-27 08:00:00\\\",\\\"2020-06-27 14:00:00\\\",\\\"2020-06-27 20:00:00\\\",\\\"2020-06-28 02:00:00\\\",\\\"2020-06-28 08:00:00\\\",\\\"2020-06-28 14:00:00\\\",\\\"2020-06-28 20:00:00\\\",\\\"2020-06-29 02:00:00\\\",\\\"2020-06-29 08:00:00\\\",\\\"2020-06-29 14:00:00\\\",\\\"2020-06-29 20:00:00\\\",\\\"2020-06-30 02:00:00\\\",\\\"2020-06-30 08:00:00\\\",\\\"2020-06-30 14:00:00\\\",\\\"2020-06-30 20:00:00\\\",\\\"2020-07-01 02:00:00\\\",\\\"2020-07-01 08:00:00\\\",\\\"2020-07-01 14:00:00\\\",\\\"2020-07-01 20:00:00\\\",\\\"2020-07-02 02:00:00\\\",\\\"2020-07-02 08:00:00\\\",\\\"2020-07-02 14:00:00\\\",\\\"2020-07-02 20:00:00\\\",\\\"2020-07-03 02:00:00\\\",\\\"2020-07-03 08:00:00\\\",\\\"2020-07-03 14:00:00\\\",\\\"2020-07-03 20:00:00\\\",\\\"2020-07-04 02:00:00\\\",\\\"2020-07-04 08:00:00\\\",\\\"2020-07-04 14:00:00\\\",\\\"2020-07-04 20:00:00\\\",\\\"2020-07-05 02:00:00\\\",\\\"2020-07-05 08:00:00\\\",\\\"2020-07-05 14:00:00\\\",\\\"2020-07-05 20:00:00\\\",\\\"2020-07-06 02:00:00\\\",\\\"2020-07-06 08:00:00\\\",\\\"2020-07-06 14:00:00\\\",\\\"2020-07-06 20:00:00\\\",\\\"2020-07-07 02:00:00\\\",\\\"2020-07-07 08:00:00\\\",\\\"2020-07-07 14:00:00\\\",\\\"2020-07-07 20:00:00\\\",\\\"2020-07-08 02:00:00\\\",\\\"2020-07-08 08:00:00\\\",\\\"2020-07-08 14:00:00\\\",\\\"2020-07-08 20:00:00\\\",\\\"2020-07-09 02:00:00\\\",\\\"2020-07-09 08:00:00\\\",\\\"2020-07-09 14:00:00\\\",\\\"2020-07-09 20:00:00\\\",\\\"2020-07-10 02:00:00\\\",\\\"2020-07-10 08:00:00\\\",\\\"2020-07-10 14:00:00\\\",\\\"2020-07-10 20:00:00\\\",\\\"2020-07-11 02:00:00\\\",\\\"2020-07-11 08:00:00\\\",\\\"2020-07-11 14:00:00\\\",\\\"2020-07-11 20:00:00\\\",\\\"2020-07-12 02:00:00\\\",\\\"2020-07-12 08:00:00\\\",\\\"2020-07-12 14:00:00\\\",\\\"2020-07-12 20:00:00\\\",\\\"2020-07-13 02:00:00\\\",\\\"2020-07-13 08:00:00\\\",\\\"2020-07-13 14:00:00\\\",\\\"2020-07-13 20:00:00\\\",\\\"2020-07-14 02:00:00\\\",\\\"2020-07-14 08:00:00\\\",\\\"2020-07-14 14:00:00\\\",\\\"2020-07-14 20:00:00\\\",\\\"2020-07-15 02:00:00\\\",\\\"2020-07-15 08:00:00\\\",\\\"2020-07-15 14:00:00\\\",\\\"2020-07-15 20:00:00\\\",\\\"2020-07-16 02:00:00\\\",\\\"2020-07-16 08:00:00\\\",\\\"2020-07-16 14:00:00\\\",\\\"2020-07-16 20:00:00\\\",\\\"2020-07-17 02:00:00\\\",\\\"2020-07-17 08:00:00\\\",\\\"2020-07-17 14:00:00\\\",\\\"2020-07-17 20:00:00\\\",\\\"2020-07-18 02:00:00\\\",\\\"2020-07-18 08:00:00\\\",\\\"2020-07-18 14:00:00\\\",\\\"2020-07-18 20:00:00\\\",\\\"2020-07-19 02:00:00\\\",\\\"2020-07-19 08:00:00\\\",\\\"2020-07-19 14:00:00\\\",\\\"2020-07-19 20:00:00\\\",\\\"2020-07-20 02:00:00\\\",\\\"2020-07-20 08:00:00\\\",\\\"2020-07-20 14:00:00\\\",\\\"2020-07-20 20:00:00\\\",\\\"2020-07-21 02:00:00\\\",\\\"2020-07-21 08:00:00\\\",\\\"2020-07-21 14:00:00\\\",\\\"2020-07-21 20:00:00\\\",\\\"2020-07-22 02:00:00\\\",\\\"2020-07-22 08:00:00\\\",\\\"2020-07-22 14:00:00\\\",\\\"2020-07-22 20:00:00\\\",\\\"2020-07-23 02:00:00\\\",\\\"2020-07-23 08:00:00\\\",\\\"2020-07-23 14:00:00\\\",\\\"2020-07-23 20:00:00\\\",\\\"2020-07-24 02:00:00\\\",\\\"2020-07-24 08:00:00\\\",\\\"2020-07-24 14:00:00\\\",\\\"2020-07-24 20:00:00\\\",\\\"2020-07-25 02:00:00\\\",\\\"2020-07-25 08:00:00\\\",\\\"2020-07-25 14:00:00\\\",\\\"2020-07-25 20:00:00\\\",\\\"2020-07-26 02:00:00\\\",\\\"2020-07-26 08:00:00\\\",\\\"2020-07-26 14:00:00\\\",\\\"2020-07-26 20:00:00\\\",\\\"2020-07-27 02:00:00\\\",\\\"2020-07-27 08:00:00\\\",\\\"2020-07-27 14:00:00\\\",\\\"2020-07-27 20:00:00\\\",\\\"2020-07-28 02:00:00\\\",\\\"2020-07-28 08:00:00\\\",\\\"2020-07-28 14:00:00\\\",\\\"2020-07-28 20:00:00\\\",\\\"2020-07-29 02:00:00\\\",\\\"2020-07-29 08:00:00\\\",\\\"2020-07-29 14:00:00\\\",\\\"2020-07-29 20:00:00\\\",\\\"2020-07-30 02:00:00\\\",\\\"2020-07-30 08:00:00\\\",\\\"2020-07-30 14:00:00\\\",\\\"2020-07-30 20:00:00\\\",\\\"2020-07-31 02:00:00\\\",\\\"2020-07-31 08:00:00\\\",\\\"2020-07-31 14:00:00\\\",\\\"2020-07-31 20:00:00\\\",\\\"2020-08-01 02:00:00\\\",\\\"2020-08-01 08:00:00\\\",\\\"2020-08-01 14:00:00\\\",\\\"2020-08-01 20:00:00\\\",\\\"2020-08-02 02:00:00\\\",\\\"2020-08-02 08:00:00\\\",\\\"2020-08-02 14:00:00\\\",\\\"2020-08-02 20:00:00\\\",\\\"2020-08-03 02:00:00\\\",\\\"2020-08-03 08:00:00\\\",\\\"2020-08-03 14:00:00\\\",\\\"2020-08-03 20:00:00\\\",\\\"2020-08-04 02:00:00\\\",\\\"2020-08-04 08:00:00\\\",\\\"2020-08-04 14:00:00\\\",\\\"2020-08-04 20:00:00\\\",\\\"2020-08-05 02:00:00\\\",\\\"2020-08-05 08:00:00\\\",\\\"2020-08-05 14:00:00\\\",\\\"2020-08-05 20:00:00\\\",\\\"2020-08-06 02:00:00\\\",\\\"2020-08-06 08:00:00\\\",\\\"2020-08-06 14:00:00\\\",\\\"2020-08-06 20:00:00\\\",\\\"2020-08-07 02:00:00\\\",\\\"2020-08-07 08:00:00\\\",\\\"2020-08-07 14:00:00\\\",\\\"2020-08-07 20:00:00\\\",\\\"2020-08-08 02:00:00\\\",\\\"2020-08-08 08:00:00\\\",\\\"2020-08-08 14:00:00\\\",\\\"2020-08-08 20:00:00\\\",\\\"2020-08-09 02:00:00\\\",\\\"2020-08-09 08:00:00\\\",\\\"2020-08-09 14:00:00\\\",\\\"2020-08-09 20:00:00\\\",\\\"2020-08-10 02:00:00\\\",\\\"2020-08-10 08:00:00\\\",\\\"2020-08-10 14:00:00\\\",\\\"2020-08-10 20:00:00\\\",\\\"2020-08-11 02:00:00\\\",\\\"2020-08-11 08:00:00\\\",\\\"2020-08-11 14:00:00\\\",\\\"2020-08-11 20:00:00\\\",\\\"2020-08-12 02:00:00\\\",\\\"2020-08-12 08:00:00\\\",\\\"2020-08-12 14:00:00\\\",\\\"2020-08-12 20:00:00\\\",\\\"2020-08-13 02:00:00\\\",\\\"2020-08-13 08:00:00\\\",\\\"2020-08-13 14:00:00\\\",\\\"2020-08-13 20:00:00\\\",\\\"2020-08-14 02:00:00\\\",\\\"2020-08-14 08:00:00\\\",\\\"2020-08-14 14:00:00\\\",\\\"2020-08-14 20:00:00\\\",\\\"2020-08-15 02:00:00\\\",\\\"2020-08-15 08:00:00\\\",\\\"2020-08-15 14:00:00\\\",\\\"2020-08-15 20:00:00\\\",\\\"2020-08-16 02:00:00\\\",\\\"2020-08-16 08:00:00\\\",\\\"2020-08-16 14:00:00\\\",\\\"2020-08-16 20:00:00\\\",\\\"2020-08-17 02:00:00\\\",\\\"2020-08-17 08:00:00\\\",\\\"2020-08-17 14:00:00\\\",\\\"2020-08-17 20:00:00\\\",\\\"2020-08-18 02:00:00\\\",\\\"2020-08-18 08:00:00\\\",\\\"2020-08-18 14:00:00\\\",\\\"2020-08-18 20:00:00\\\",\\\"2020-08-19 02:00:00\\\",\\\"2020-08-19 08:00:00\\\",\\\"2020-08-19 14:00:00\\\",\\\"2020-08-19 20:00:00\\\",\\\"2020-08-20 02:00:00\\\",\\\"2020-08-20 08:00:00\\\",\\\"2020-08-20 14:00:00\\\",\\\"2020-08-20 20:00:00\\\",\\\"2020-08-21 02:00:00\\\",\\\"2020-08-21 08:00:00\\\",\\\"2020-08-21 14:00:00\\\",\\\"2020-08-21 20:00:00\\\",\\\"2020-08-22 02:00:00\\\",\\\"2020-08-22 08:00:00\\\",\\\"2020-08-22 14:00:00\\\",\\\"2020-08-22 20:00:00\\\",\\\"2020-08-23 02:00:00\\\",\\\"2020-08-23 08:00:00\\\",\\\"2020-08-23 14:00:00\\\",\\\"2020-08-23 20:00:00\\\",\\\"2020-08-24 02:00:00\\\",\\\"2020-08-24 08:00:00\\\",\\\"2020-08-24 14:00:00\\\",\\\"2020-08-24 20:00:00\\\",\\\"2020-08-25 02:00:00\\\",\\\"2020-08-25 08:00:00\\\",\\\"2020-08-25 14:00:00\\\",\\\"2020-08-25 20:00:00\\\",\\\"2020-08-26 02:00:00\\\",\\\"2020-08-26 08:00:00\\\",\\\"2020-08-26 14:00:00\\\",\\\"2020-08-26 20:00:00\\\",\\\"2020-08-27 02:00:00\\\",\\\"2020-08-27 08:00:00\\\",\\\"2020-08-27 14:00:00\\\",\\\"2020-08-27 20:00:00\\\",\\\"2020-08-28 02:00:00\\\",\\\"2020-08-28 08:00:00\\\",\\\"2020-08-28 14:00:00\\\",\\\"2020-08-28 20:00:00\\\",\\\"2020-08-29 02:00:00\\\",\\\"2020-08-29 08:00:00\\\"]\",\"rain\":\"[0.22628205128205134,4.708974382051281,7.614102505128206,2.406410276923076,0.5166666666666668,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.010256410256410256,0.5589743615384615,1.3664283846153845E-17,1.3664283846153845E-17,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.005128205128205128,0.016025641025641024,0.016025641025641024,0.016025641025641024,0.5826923076923076,1.0371794769230767,0.632051282051282,0.03205128205128205,0.6269230769230769,1.954678654615384,4.053213448717948,0.13964369015384617,0.17041292092307694,0.01282051282051282,0.0,0.0,0.01282051282051282,0.0,0.0,0.0,0.005128205128205128,0.026282051282051314,3.9775641358974365,0.03910256410256413,0.06987179487179489,0.015384615384615385,0.0,0.020512820512820513,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.023717948717948717,0.023717948717948717,0.0391025641025641,0.023717948717948717,0.08012820512820512,0.08012820512820512,2.1365384717948714,0.13653846153846155,0.0,0.0,0.0,0.11282051538461535,3.7493589666666676,3.023717948717948,1.6621794358974358,0.38525641025641033,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.005128205128205128,0.0,0.005128205128205128,0.0,0.0,0.0,0.002564102564102564,0.022435897435897436,0.10705128205128205,0.027564102564102563,0.025,0.0,0.0,0.0,0.005128205128205128,0.0,0.0,0.0,0.005128205128205128,0.0,0.038461538461538464,0.002564102564102564,0.007692307692307692,0.10740563846153849,3.4102139307692303,0.11600042564102563,0.10740563846153849,0.07307692307692307,0.2705128307692307,0.17051282307692303,0.07564102564102564,0.8249999761538465,43.05320479487179,7.753205132564103,0.33012820692307726,0.050641025641025635,1.4839743589743588,0.3096153846153846,0.06858974358974358,0.010256410256410256,0.0,0.005128205128205128,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.06474358974358974,0.06474358974358974,0.06474358974358974,0.06474358974358974,0.0,0.4615384615384615,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.009615384615384616,0.009615384615384616,0.2762820512820513,0.2711538461538462,0.04358974358974359,0.01282051282051282,0.002564102564102564,0.002564102564102564,0.0,0.0,0.0,0.0,0.0,0.02564102564102564,0.0,0.0,0.35384615384615387,0.046153846153846156,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.015384615384615384,0.09230769230769231,0.0,0.16923076923076924,0.04358974358974359,0.0641025641025641,0.0,0.0,0.11538461538461538,0.10256410256410256,0.0,1.574358974358974,5.880641017948719,0.9493589743589744,10.04474363333333,0.8688461533333331,0.010256410256410256,0.005128205128205128,0.0,0.0,0.49287545538461536,18.803937728205128,3.4626190553846143,0.3610805861538461,0.017948717948717947,0.4923076923076923,0.0,0.0,0.005128205128205128,0.0,0.3205128205128206,0.03333333333333333,1.1673076923076922,5.223717976923076,0.11602564102564104,0.11089743589743595,0.005128205128205128,0.0,0.0,0.0,0.0,0.020512820512820513,0.0,0.0,0.0,0.0,0.0,0.0,0.005128205128205128,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.5256410256410257,0.0,0.0,0.003205128205128205,0.003205128205128205,0.008333333333333333,0.1032051282051282,0.0,0.0,0.0,0.0,0.20213675282051283,0.6303418810256409,1.1414529974358971,3.8491453256410253,5.880442891025641,0.26044289094871803,0.23212121171794878,0.27571095530769235,0.005128205128205128,0.0,0.0,0.0,0.0,0.24358974358974358,0.05128205128205128,0.005128205128205128,0.11474358974358977,0.11474358974358977,0.11474358974358977,3.6198717999999994,4.239993310256409,0.2806859794871795,0.14991674871794877,0.1550449538461539,1.8108669146153846,9.751587184615383,4.380525015384615,1.018559222307692,0.05128205128205129,0.14615384615384616,0.01282051282051282,0.0,0.01282051282051282,0.005128205128205128,0.0,0.005128205128205128,0.0,0.1282051282051282,0.0,0.010256410256410256,0.005128205128205128,0.0,0.0,0.002564102564102564,0.515688258974359,0.515688258974359,1.0417566358974357,14.931995166666667,9.302732843589748,0.3426788141025641,0.32985830128205135,0.3811403525641025,0.0,0.005128205128205128,0.0,0.0,0.18453666153846154,0.18966486666666668,0.7832321230769228,6.429745943589742,11.533333294871797,1.8521870512820509,0.8328808474358972,0.7149321294871793,0.049358974358974364,0.010897435897435897,0.016025641025641024,0.010897435897435897]\",\"B\":\"0.2\",\"WM\":\"120\",\"start\":\"\\\"2020-06-30 08:00:00\\\"\",\"ES\":\"[23.8, 23.2, 33.7, 53, 66.6, 78.9, 122.3, 113.9, 90.8, 62.9, 46.2, 34.1]\",\"WP\":\"30.000\"}";
        Map data = JSON.parseObject(a, Map.class);
        SM obj = new SM(data);
        System.out.println(obj.predict());
    }

}